package movement;

import jgame.JGObject;
import jgame.impl.JGEngineInterface;

public class BasicPlayerMovement implements MoveModel {

	private double speedFactor;
	private double accelerationFactor;
	
	public BasicPlayerMovement(double speedFactor, double accelerationFactor){
		this.speedFactor = speedFactor;
		this.accelerationFactor = accelerationFactor;
	}
	
	
	@Override
	public void move(JGObject obj){ 
		
		if (obj.eng.getKey(JGEngineInterface.KeyLeft)){
			obj.x = obj.x - speedFactor;
			obj.xspeed = obj.xspeed - accelerationFactor;
			obj.setAnim("player_l");
		} 
		if (obj.eng.getKey(JGEngineInterface.KeyUp)){
			obj.y = obj.y - speedFactor;
			obj.yspeed = obj.yspeed - accelerationFactor;
			obj.setAnim("player_d");
		} 
		if (obj.eng.getKey(JGEngineInterface.KeyRight)){
			obj.x = obj.x + speedFactor;
			obj.xspeed = obj.xspeed + accelerationFactor;
			obj.setAnim("player_r");
		}
		if (obj.eng.getKey(JGEngineInterface.KeyDown)){
			obj.y = obj.y + speedFactor;
			obj.yspeed = obj.yspeed + accelerationFactor;
			obj.setAnim("player_u");
		}
		
		if (obj.eng.getLastKey() == JGEngineInterface.KeyEnter){
			obj.xspeed = obj.yspeed = 0;
		}
	}
	
	
}

